package com.zmc.admin.infrastructure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zmc.admin.infrastructure.bean.query.SysNoticeQuery;
import com.zmc.common.utils.PageUtils;
import com.zmc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.zmc.admin.infrastructure.dao.SysNoticeDao;
import com.zmc.admin.infrastructure.entity.SysNoticeEntity;
import com.zmc.admin.infrastructure.service.SysNoticeService;


@Service("sysNoticeService")
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeDao, SysNoticeEntity> implements SysNoticeService {


    @Override
    public PageUtils selectNoticeList(SysNoticeQuery query) {
        LambdaQueryWrapper<SysNoticeEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StringUtils.isNotEmpty(query.getNoticeTitle()), SysNoticeEntity::getNoticeTitle, query.getNoticeTitle())
                .eq(StringUtils.isNotEmpty(query.getNoticeType()), SysNoticeEntity::getNoticeType, query.getNoticeType())
                .eq(StringUtils.isNotEmpty(query.getCreateBy()), SysNoticeEntity::getCreateBy, query.getCreateBy());
        Page<SysNoticeEntity> page = baseMapper.selectPage(new Page<>(query.getPageNum(), query.getPageSize()), wrapper);
        return new PageUtils(page);
    }
}